function main2222() {
    var library_name = "libFairGuard.so" // ex: libsqlite.so
    var loaded = false
    var enums = Module.enumerateSymbols("linker")
    var dlopen = null
    for (var i =0 ; i< enums.length ; i++ ){
        if(enums[i].name == "__dl__ZL10dlopen_extPKciPK17android_dlextinfoPKv"){
            dlopen = enums[i].address
        }
    }
    var i = 0
    console.log("dlopen", dlopen)
    Interceptor.attach(dlopen,{
        onEnter: function(args){
            var library_path = Memory.readCString(args[0])
           // console.log("found library : " + library_path)
            if( library_path.includes(library_name)){
                console.log("found library : " + library_path)
                loaded = true
            }
        },
        onLeave: function(args){
            if(loaded){
           var jni_OnLoad = Module.findExportByName(library_name,"JNI_OnLoad")
           var base_addr = Module.findBaseAddress(library_name)
           console.log("base_addr : " + base_addr)
           console.log("jni_OnLoad_symbol : " + jni_OnLoad)
           Interceptor.attach(jni_OnLoad ,{
                onEnter: function(args){
                    console.log('jni_OnLoad')
                    },
                    onLeave: function(ret){
                    console.log('jni_OnLoad ret')
         
                    Interceptor.attach(Module.findExportByName(null, "fopen"), {

                        onEnter: function(args) {
                            if (args[0].isNull()) return;
                            var path = args[0].readUtf8String();
                          
                            if(path.indexOf('base.apk') != -1 ){
                                console.log("fopen " + path)
                                i ++
                                if (i==2){
                                    var oriapk = Memory.allocUtf8String('/storage/emulated/0/1.apk')
                                    // var oriapk = Memory.allocUtf8String('/data/app/cn.alltune.endless-jhzSD_RF72AvONf2iga6UA==/base.apk')
                                    //args[0] = oriapk
                                   // path = args[0].readUtf8String();
                                    console.log("replace fopen " + oriapk)
                                }else{

                                }
                      
                                // console.log(
                                //     Thread.backtrace(this.context, Backtracer.ACCURATE)
                                //     .map(DebugSymbol.fromAddress).join('\n') + '\n')
                            }
                            
                    
                        },
                        onLeave: function(retval) {
                            // console.log("\t[-] Type of return value: " + typeof retval);
                            // console.log("\t[-] Original Return Value: " + retval);
                            // retval.replace(0);  //将返回值替换成0
                            // console.log("\t[-] New Return Value: " + retval);
                        },
                    })

                }
              })
              loaded = false
            }
        }
    })
   

}

setImmediate(main2222);


// frida -U com.hnzh.dldlwhjx.aligames -l c2ddldl

// frida -U --no-pause -f com.ftaro.kingwar.tyhjz -l c2dty

// frida -U com.ftaro.kingwar.tyhjz -l c2dty
// frida -U cn.alltune.endless -l u3dtest

// frida -U --no-pause -f com.youzu.ss0.yuewbox -l u3dtest


// frida -U --no-pause -f cn.alltune.endless -l u3dtest
// frida -U --no-pause -f com.xlxx.sshg.aligames -l u3dtest.js
